<?
session_start();
require_once 'config.php';
if($_SESSION['cart']) {
   $arr_pro_id = $_SESSION['cart'];
   foreach($arr_pro_id as $key=>$value){
      $str_pro_id .= $key.',';
   }
   $str_pro_id = rtrim($str_pro_id,',');
   $products = db_array("SELECT * FROM products WHERE pro_id IN(".$str_pro_id.")");
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="vi" lang="vi" xmlns:og="http://ogp.me/ns#" xmlns:fb="">
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <link type="image/x-icon" href="/favicon.ico" rel="icon" />
   
   <title>Giỏ hàng</title>
   <meta name="description" content=""/>
   <meta name="keywords" content=""/>
   <meta name="AUTHOR" content="Bảo hộ lao động Đông Anh" />
   <meta name="COPYRIGHT" content="Sudo.vn" />
   <meta name="ROBOTS" content="INDEX, FOLLOW" />
   <meta name="RATING" content="GENERAL" />
   
   <meta property="og:title" content="" />
   <meta property="og:type" content="website" />
   <meta property="og:url" content="" />
   <meta property="og:image" content="" />
   <meta property="og:site_name" content="" />
   <meta property="og:description" content="" />
   <meta property="fb:admins" content="" />
   <meta property="fb:app_id" content=""/> 
   <!-- css -->   
   <link rel="stylesheet" type="text/css" href="<?=TEMPLATE_PATH?>css/home.css" />	
   <link rel="stylesheet" type="text/css" href="<?=TEMPLATE_PATH?>css/product.css" />
   <!-- js -->
   <script type="text/javascript" src="<?=TEMPLATE_PATH?>js/jquery-1.9.0.min.js"></script>
   <script type="text/javascript" src="<?=TEMPLATE_PATH?>js/common.js"></script>
   <style>
   .cart_pro_number{
      float: left;
      width: 60px;
      padding-left: 3px;
      margin-left: 5px;
      height: 22px;
   }
   .status_img{
      float: left;
      width: 25px;
      height: 25px;
      margin-left: 3px;
   }
   .status_img img{
      float: left;
      width: 25px;
      height: 25px;
      margin: 0;
      margin-left: 3px;
   }
   .submit_orders{
      background: #d00054;      
      height: 25px;
      border-radius: 2px;
      text-align: center;
      color: #fff;
      line-height: 25px;
      font-weight: bold;
      border: none;
      cursor: pointer;
      padding: 0 5px;
   }
   .product{
      position: relative;
   }
   .delete_cart_this{
      position: absolute;
      top: 2px;
      right:2px;
   }
   </style>
</head>
<body>   
   <? include('view/common/vic_header.php');?>
   <div class="global_container">
      <div class="slider">
         <?include('view/common/vic_slide.php')?>
      </div>
      <div class="content_wrap">
         <div class="content_left">
            <?include('view/common/vic_content_left.php')?>
            
         </div>
         <div class="content_right">
            <div class="products_hot_wrap">
               <h1 class="pro_hot_title">
                  Bạn có <?=count($arr_pro_id)?> sản phẩm trong giỏ hàng 
                  <?if($products){?>
                  - <a href="javascript:;" class="delete_cart">Xóa giỏ hàng</a>
                  
                  - <a type="submit" class="submit_orders" href="/dat-mua-gio-hang.html">Đặt mua toàn bộ giỏ hàng</a>
                  <? } ?>
               </h1>
               <div class="products_hot">
               <?
                  $i = 0;
                  if($products){
                     ?>
                     <div class="products_hot">
                     
                        <?
                           $i = 0;
                           foreach($products as $row){
                              $i++;
                        ?>
                        <div class="product <?=($i%2 == 0) ? 'mgr0':''?>">
                           <img src="<?=($row['pro_image'] != '') ? product_images.$pro_img_small.$row['pro_image'] : '/pictures/no.jpg'?>"/>
                           <div class="product_info">
                              <p class="product_name"><a href="<?=generate_product_detail_url($row)?>"><?=$row['pro_name']?></a></p>
                              <p class="product_description">
                                 <?=cut_string($row['pro_description'],100)?>
                              </p>
                              <a class="buy" href="<?=generate_product_order_url($row)?>">ĐẶT MUA</a>
                              <input type="text" name="pro_number[]" placeholder="Số lượng" class="cart_pro_number cart_pro_number<?=$row['pro_id']?>" value="<?=$arr_pro_id[$row['pro_id']]?>" pro_id="<?=$row['pro_id']?>"/>
                              <div class="status_img status_img<?=$row['pro_id']?>"></div>
                           </div>
                           <a href="javascript:;" class="delete_cart_this" pro_id ="<?=$row['pro_id']?>">Xóa</a>
                        </div>
                        <? 
                           }
                        ?>
                        </form>
                     </div>
                     <?
                    
                  }else{
                     echo "Bạn không có sản phẩm nào trong giỏ hàng !";
                  } ?>
                  
               </div>
               <div class="products_pagebreak">
                  <?=generatePageBar('',$current_page,$templateProduct->page_size,$total,'','main_page_btn','page_selected','<<','>>','Đầu','Cuối',1,1)?>
               </div>
            </div>
         </div>
      </div>
      <?include('view/common/vic_social_networking.php');?>
   </div>
   <?include('view/common/vic_footer.php');?>
</body>
</html>
